﻿##############################################################################
###### UNITY
##############################################################################


evaluate_action_decreasing_house_unity = {
	modifier = {
		desc = DECREASE_UNITY_DESC
		scope:actor = {
			OR = {
				government_has_flag = government_is_feudal
				government_has_flag = government_is_administrative
			}
			exists = scope:recipient.house
			house ?= scope:recipient.house
		}
		add = {
			value = $VALUE$ # The value is set by the content calling the unity effect; we want it to be alligned with the other modifiers
			# Then different parameters apply a factor on the value

			### Personality
			# Warmonger and Ambitious AI wants a low unity to expand while peaceful and economy focused wants Harmonious
			if = {
				limit = { ai_wants_high_unity = yes }
				multiply = 0.8
			}
			else_if = {
				limit = { ai_wants_low_unity = yes }
				multiply = 1.2
			}

			### House Head related
			# Do I want to  take the title?
			if = {
				limit = {
					# if you are aboe impassive, you really want to lower unity
					house ?= {
						OR = {
							has_house_unity_stage = harmonious
							has_house_unity_stage = friendly
							has_house_unity_stage = impassive

						}
					}
					# only valid for some personnality, and not the heir of the current house head
					AND = {
						OR = {
							has_trait = ambitious
							has_trait = deceitful
							has_trait = greedy
						}
						NOT = { is_heir_of = house.house_head }
					}

				}
				multiply = 1.2
			}

			### Struggle
			if = {
				limit = { has_trait = fp3_struggle_detractor }
				multiply = 1.5
			}
			else_if = {
				limit = { has_trait = fp3_struggle_supporter }
				multiply = 0.5
			}

			### Current Unity state
			# lower the overall weight if unity is already low: you don't care of lowering unity if you are at 0
			if = {
				limit = {
					house ?= {
						has_house_unity_stage = harmonious
					}
				}
				multiply = 1.2
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = friendly
					}
				}
				multiply = 1.1
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = competitive
					}
				}
				multiply = 0.9
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = antagonistic
					}
				}
				multiply = {
					value = 0.8
					if = {
						limit = {
							house ?= { house_unity_value <= critical_house_unity }
						}
						multiply = 0.5
					}
				}
			}
		}
	}
}

evaluate_action_increasing_house_unity = {
	modifier = {
		desc = INCREASE_UNITY_DESC
		scope:actor = {
			OR = {
				government_has_flag = government_is_feudal
				government_has_flag = government_is_administrative
			}
			house ?= scope:recipient.house
		}
		add = {
			value = $VALUE$ # The value is set by the content calling the unity effect; we want it to be alligned with the other modifiers
			# Then different parameters apply a factor on the value

			### Personality
			# Warmonger and Ambitious AI wants a low unity to expand while peaceful and economy focused wants Harmonious
			if = {
				limit = { ai_wants_high_unity = yes }
				multiply = 1.2
			}
			else_if = {
				limit = { ai_wants_low_unity = yes }
				multiply = 0.8
			}

			### House Head related
			# Do I want to  be rescued if outside of the realm
			if = {
				limit = {
					# if you are under impassive, you really want to increase unity
					house ?= {
						OR = {
							has_house_unity_stage = antagonistic
							has_house_unity_stage = competitive
							has_house_unity_stage = impassive

						}
					}
					# only valid for people outside of their liege realm
					NOR ={
						house.house_head = top_liege
						house.house_head = liege
					}

				}
				multiply = 1.2
			}

			### Struggle
			if = {
				limit = { has_trait = fp3_struggle_supporter }
				multiply = 1.5
			}
			else_if = {
				limit = { has_trait = fp3_struggle_detractor }
				multiply = 0.5
			}

			### Current Unity state
			# lower the overall weight if unity is already high: you don't care of increasing unity if you are at 100
			if = {
				limit = {
					house ?= {
						has_house_unity_stage = antagonistic
					}
				}
				multiply = 1.2
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = competitive
					}
				}
				multiply = 1.1
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = friendly
					}
				}
				multiply = 0.9
			}
			else_if = {
				limit = {
					house ?= {
						has_house_unity_stage = harmonious
					}
				}
				multiply = {
					value = {
						add = 0.8
						if = {
							limit = {
								house ?= { house_unity_value >= very_high_house_unity }
							}
							multiply = 0.5
						}
					}
				}
			}
		}
	}
}

fp3_challenge_house_head_negotiation_bargain_modifier = {
	ai_value_modifier = {
		who = scope:recipient
		ai_energy = -0.25
		ai_boldness = -0.25
		ai_greed = 0.25
		ai_rationality = 0.25
	}
}

fp3_challenge_house_head_negotiation_reject_modifier = {
	opinion_modifier = {
		who = scope:recipient
		opinion_target = scope:actor
		multiplier = -0.25
	}
	ai_value_modifier = {
		who = scope:recipient
		ai_energy = 0.5
		ai_boldness = 0.5
		ai_greed = 0.5
		ai_rationality = 0.5
		ai_honor = 0.25
	}
}

fp3_challenge_house_head_negotiation_strength_modifier = {
	# Vassal
	modifier = {
		$OTHER$ = { is_vassal_or_below_of = $CHARACTER$ }
		add = 5
	}
	# Tier
	modifier = {
		add = {
			value = $CHARACTER$.highest_held_title_tier
			multiply = 2
		}
	}
	# Military
	modifier = {
		add = {
			value = $CHARACTER$.max_military_strength
			divide = 1000
			multiply = 2
		}
	}
}

##################################################
# #Struggle Modifiers

fp3_struggle_0001_change_sides_weight_modifier = {
	# Weight up for dukes.
	modifier = {
		add = 50
		highest_held_title_tier = tier_duchy
	}
	# Weight up for kings & emperors.
	modifier = {
		add = 100
		highest_held_title_tier >= tier_kingdom
	}
}

fp3_struggle_resist_allied_wars_modifier = {
	modifier = {  # Opposing struggle sides don't want to join.
		add = -100
		OR = {
			AND = {
				scope:actor = { has_trait = fp3_struggle_detractor }
				scope:recipient = { has_trait = fp3_struggle_supporter }
			}
			AND = {
				scope:actor = { has_trait = fp3_struggle_supporter }
				scope:recipient = { has_trait = fp3_struggle_detractor }
			}
		}
		desc = WONT_HELP_STRUGGLE_FOE_REASON
	}
}

##################################################
# #Decision Modifiers

fp3_misc_decisions_0031_preferred_cultrads_modifier = {
	# Weight up for some traditions.
	## Always.
	modifier = {
		add = 2
		culture = { has_cultural_tradition = tradition_xenophilic }
	}
	modifier = {
		add = 2
		culture = { has_cultural_tradition = tradition_loyal_soldiers }
	}
	modifier = {
		add = 2
		culture = { has_cultural_tradition = tradition_parochialism }
	}
	modifier = {
		add = 1
		culture = { has_cultural_tradition = tradition_culture_blending }
	}
	modifier = {
		add = 1
		culture = { has_cultural_tradition = tradition_talent_acquisition }
	}
	modifier = {
		add = 1
		culture = { has_cultural_tradition = tradition_welcoming }
	}
	## Circumstantial.
	### Eloquent Captains
	modifier = {
		add = 1
		scope:outsider_diplomacy_martial = yes
		culture = { has_cultural_tradition = tradition_astute_diplomats }
	}
	modifier = {
		add = 1
		scope:outsider_diplomacy_martial = yes
		culture = { has_cultural_tradition = tradition_fp2_state_ransoming }
	}
	### Career Soldiers
	modifier = {
		add = 1
		scope:outsider_martial_prowess = yes
		culture = { has_cultural_tradition = tradition_fp2_state_ransoming }
	}
	### Fringe Nobility
	modifier = {
		add = 1
		scope:outsider_prowess_learning = yes
		culture = { has_cultural_tradition = tradition_astute_diplomats }
	}
	modifier = {
		add = 1
		scope:outsider_prowess_learning = yes
		culture = { has_cultural_tradition = tradition_fp2_state_ransoming }
	}
	### Dedicated Functionaries
	modifier = {
		add = 1
		scope:outsider_learning_intrigue = yes
		culture = { has_cultural_tradition = tradition_legalistic }
	}
	modifier = {
		add = 1
		scope:outsider_learning_intrigue = yes
		culture = { has_cultural_tradition = tradition_monastic_communities }
	}
	### Cunning Officials
	modifier = {
		add = 1
		scope:outsider_intrigue_stewardship = yes
		culture = { has_cultural_tradition = tradition_legalistic }
	}
	modifier = {
		add = 1
		scope:outsider_intrigue_stewardship = yes
		culture = { has_cultural_tradition = tradition_maritime_mercantilism }
	}
	modifier = {
		add = 1
		scope:outsider_intrigue_stewardship = yes
		culture = { has_cultural_tradition = tradition_monastic_communities }
	}
	### Skilled Administrators
	modifier = {
		add = 1
		scope:outsider_stewardship_diplomacy = yes
		culture = { has_cultural_tradition = tradition_legalistic }
	}
	modifier = {
		add = 1
		scope:outsider_stewardship_diplomacy = yes
		culture = { has_cultural_tradition = tradition_monastic_communities }
	}
	# And weight down for others.
	## Always.
	modifier = {
		add = -3
		culture = { has_cultural_tradition = tradition_isolationist }
	}
	modifier = {
		add = -1
		culture = { has_cultural_tradition = tradition_quarrelsome }
	}
}
